﻿Imports HtmlAgilityPack
Imports NWTCompiler.StaticValues
Imports NWTCompiler.GetTranslations
Imports System.Text

Public Class Form1

	Private Function FormatResultsAsCode(myTranslations As List(Of KeyValuePair(Of String, Translation))) As String
		Dim returnString As New StringBuilder

		myTranslations.Add(New KeyValuePair(Of String, Translation)("http://m.wol.jw.org/en/wol/b/r1/lp-e/Rbi8/E/1984/", New Translation("en1984", "English (1984)", False, True, True)))
		myTranslations.Add(New KeyValuePair(Of String, Translation)("zhuyin~http://wol.homenet.org/zh-Hans/wol/b/r23/lp-chs/", New Translation("zh-Zhuyin", "ㄅㄆㄇㄈ", False, True, True)))
		myTranslations.Add(New KeyValuePair(Of String, Translation)("sydneylau~http://wol.homenet.org/zh-Hans/wol/b/r23/lp-chs/", New Translation("zh-Sidney Lau", "Sidney Lau", False, True, True)))
		myTranslations.Add(New KeyValuePair(Of String, Translation)("pinyin~http://wol.homenet.org/zh-Hans/wol/b/r23/lp-chs/", New Translation("zh-Pinyin", "Hànyu Pinyin", False, True, True)))

		For Each myTranslation In myTranslations.OrderBy(Function(x) x.Value.LanguageCode)
			With myTranslation
				returnString.AppendLine(String.Format("_AvailableLanguages.Add( New Translation(""{0}"", ""{1}"", ""{2}"", {3}, {4}, {5})))", .Key, .Value.LanguageCode, .Value.Language, .Value.RightToLeft, .Value.Hebrew, .Value.Greek))
			End With
		Next

		returnString.AppendLine(String.Format("'{0} translations.", myTranslations.Count))

		Return returnString.ToString
	End Function

	Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
		TextBox1.Text = FormatResultsAsCode(GetLanguageData(GetLanguages))
	End Sub
End Class
